package com.company.OfferGuide;

import com.company.TreeNode;

import java.util.*;

public class 二叉搜索树的第k大节点 {

    private List<Integer> list = new ArrayList<>();
    public int kthLargest(TreeNode root, int k) {
        afterOrder(root);
        return list.get(list.size() - k);
    }

    public void afterOrder(TreeNode node) {
        if (node == null) return;
        afterOrder(node.left);
        list.add(node.val);
        afterOrder(node.right);
    }

}
